package com.vcms.view.simulation.uicomponent.listener;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.vcms.controller.customer.CoinReceiver;
import com.vcms.exception.VMCSException;

public class CoinInputListener implements ActionListener {

	private CoinReceiver coinReceive;

	public CoinInputListener(CoinReceiver cr) {
		coinReceive = cr;
	}

	public void actionPerformed(ActionEvent e) {

		String cmd;
		double weight;
		Button btn;

		btn = (Button) e.getSource();
		cmd = btn.getActionCommand();
		weight = Double.parseDouble(cmd);

		try {
			coinReceive.receiveCoin(weight);
		} catch (VMCSException e1) {
//			MessageDialog msg = new MessageDialog(coinReceive.getTransactionController().getPanel(),e1.getMessage());
			// e1.printStackTrace();
		}
	}

}
